package com.iot.core.data;

import lombok.Data;

@Data
public class Sort {
    private  String filed="";
    private boolean  asc;
    @Override
    public  String toString(){
        var sb=new StringBuilder();

        for(var i=0;i<filed.length();i++){
            if(Character.isUpperCase(filed.charAt(i)  )){
                if(i!=0){
                    sb.append("_");
                }
                sb.append( Character.toLowerCase(filed.charAt(i)) );


            }
            else{
                sb.append(filed.charAt(i) );
            }

        }
        return String.format("%s %s",sb.toString(),asc?"asc":"desc");
    }
}
